package com.ktgj.hotel.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ktgj.common.log.annotation.Log;
import com.ktgj.common.log.enums.BusinessType;
import com.ktgj.common.security.annotation.PreAuthorize;
import com.ktgj.hotel.domain.HotelOrderPaydetail;
import com.ktgj.hotel.service.IHotelOrderPaydetailService;
import com.ktgj.common.core.web.controller.BaseController;
import com.ktgj.common.core.web.domain.AjaxResult;
import com.ktgj.common.core.utils.poi.ExcelUtil;
import com.ktgj.common.core.web.page.TableDataInfo;

/**
 * 支付明细
Controller
 * 
 * @author ruoyi
 * @date 2021-12-08
 */
@ControllerAdvice
@RestController
@RequestMapping("/paydetail")
public class HotelOrderPaydetailController extends BaseController
{
    @Autowired
    private IHotelOrderPaydetailService hotelOrderPaydetailService;

    /**
     * 查询支付明细
列表
     */
    @PreAuthorize(hasPermi = "hotel:paydetail:list")
    @GetMapping("/list")
    public TableDataInfo list(HotelOrderPaydetail hotelOrderPaydetail)
    {
        startPage();
        List<HotelOrderPaydetail> list = hotelOrderPaydetailService.selectHotelOrderPaydetailList(hotelOrderPaydetail);
        return getDataTable(list);
    }

    /**
     * 导出支付明细
列表
     */
    @PreAuthorize(hasPermi = "hotel:paydetail:export")
    @Log(title = "支付明细 ", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotelOrderPaydetail hotelOrderPaydetail) throws IOException
    {
        List<HotelOrderPaydetail> list = hotelOrderPaydetailService.selectHotelOrderPaydetailList(hotelOrderPaydetail);
        ExcelUtil<HotelOrderPaydetail> util = new ExcelUtil<HotelOrderPaydetail>(HotelOrderPaydetail.class);
        util.exportExcel(response, list, "支付明细数据");
    }

    /**
     * 获取支付明细
详细信息
     */
    @PreAuthorize(hasPermi = "hotel:paydetail:query")
    @GetMapping(value = "/{paydetailid}")
    public AjaxResult getInfo(@PathVariable("paydetailid") Long paydetailid)
    {
        return AjaxResult.success(hotelOrderPaydetailService.selectHotelOrderPaydetailById(paydetailid));
    }

    /**
     * 查询支付明细
     *
     * @param orderid 订单ID
     * @return 支付明细

     */
    @GetMapping("/selectHotelOrderPaydetailByorderId")
    public AjaxResult selectHotelOrderPaydetailByorderId(@RequestParam("orderid") Long orderid) {
        return AjaxResult.success(hotelOrderPaydetailService.selectHotelOrderPaydetailByorderId(orderid));
    }

    /**
     * 新增支付明细

     */
    @PreAuthorize(hasPermi = "hotel:paydetail:add")
    @Log(title = "支付明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotelOrderPaydetail hotelOrderPaydetail)
    {
        return toAjax(hotelOrderPaydetailService.insertHotelOrderPaydetail(hotelOrderPaydetail));
    }

    /**
     * 修改支付明细

     */
    @PreAuthorize(hasPermi = "hotel:paydetail:edit")
    @Log(title = "支付明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotelOrderPaydetail hotelOrderPaydetail)
    {
        return toAjax(hotelOrderPaydetailService.updateHotelOrderPaydetail(hotelOrderPaydetail));
    }

    /**
     * 修改支付明细
     *
     * @param hotelOrderPaydetail 支付明细
     * @return 结果
     */
    @PostMapping("/updateOrderPaydetailByOrderId")
    public AjaxResult updateOrderPaydetailByOrderId(@RequestBody HotelOrderPaydetail hotelOrderPaydetail) {
        return toAjax(hotelOrderPaydetailService.updateOrderPaydetailByOrderId(hotelOrderPaydetail));
    }

    /**
     * 删除支付明细

     */
    @PreAuthorize(hasPermi = "hotel:paydetail:remove")
    @Log(title = "支付明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{paydetailids}")
    public AjaxResult remove(@PathVariable Long[] paydetailids)
    {
        return toAjax(hotelOrderPaydetailService.deleteHotelOrderPaydetailByIds(paydetailids));
    }
}
